<%@ taglib uri="/tld/extremecomponents" prefix="ec" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Map"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

	<script src = "../js/jquery-1.12.1.js" type = "text/javascript"></script>
	<script src = "../js/common.js" type = "text/javascript"></script>
	
	<link href="<%=request.getContextPath() %>/css/extremecomponents.css" rel="stylesheet" type="text/css" />
	<link href="<%=request.getContextPath() %>/css/global.css" rel="stylesheet" type="text/css" />
<title>课程管理</title>
<script type="text/javascript">
$(function() {
    //查询
    $("#btnsearch").click(
        function() {
            formPost(window.SearchState, '','login?ActionType=course_select', this);
        });
    //创建任务
    $("#btnadd").click(
    	    function() {
    	        formPost(window.SearchState, '','login?ActionType=course_AddInit&FLAG=add', this);
    	    });
    	});
	//修改用户状态：使用->停用；停用->使用
	function state_change(userCode){
	    $.ajax({
	        type : "post",
	        dataType : "text",
	        url : "login?ActionType=task_StateChange&CLASS_ID='class_id'&COURSE_ID='course_id'",
	        data : {},
	        success : function(massage) {
	            if (massage == 'success') {
	            	goTo("login?ActionType=login_SelectInit");
	            }
	        }
	    });
	};   
	

</script>
</head>
<body>
<%
	//用于不点击按钮，直接显示数据（ectable中的items需要从request域中取值）
	List<Map<String, String>> COURSE=(List<Map<String, String>>)request.getSession().getAttribute("COURSE");
	System.out.println(COURSE.get(0).get("course_id"));
	request.setAttribute("COURSE", COURSE);
	Map<String, String> CONDITIONMAP=(Map<String, String>)request.getSession().getAttribute("CONDITIONMAP");
	request.setAttribute("CONDITIONMAP", CONDITIONMAP);
%>
<div id="current"><span style="padding-left:10px;">当前位置：课程管理</span></div>
<form name="SearchState"   method="post" >
  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="search_table">
    <tr class="search_title_tr">
      <td colspan="5" class="search_title_L"><img src="../images/search_titleleft.jpg" width="84" height="27" align="top" /></td>
      <td width="25%" class="search_title_R"><img src="../images/search-titleright.jpg" width="8" height="27" align="top" /></td>
    </tr>

    <tr>
      <td width="15%" class="search_td1">课程名</td>
      <td  width="19%" class="search_td2">
        <input name="COURSE_NAME" type="text" size="18" value="<c:out value='${CONDITIONMAP.COURSE_NAME}'/>" />
      </td>
    
      <td width="15%" class="search_td1">班级</td>
      <td width="19%" class="search_td2">
        <input name="CLASS_NAME" type="text" size="18" value="<c:out value='${CONDITIONMAP.CLASS_NAME}'/>" />
   
      </td>
      <td width="12%" class="search_td1">状态：</td>
      <td width="26%" class="search_td2">
        <select name = "USER_STATUS" id = "USER_STATUS">
         	<option value = "">全部</option>
        	<option value = "0">未使用</option>
        	<option value = "1" >使用中</option>
        </select>
      </td>
     </tr>
    <tr>
    <td style="padding-top:3px;">
       <input class="btn_2" id="btnsearch" name="btnsearch" type="button"  value="查询" />
       <input id="btnadd" name="btnadd" type="button" class="btn_4" value="新建任务" /></td>
  </table>
</form>
  
<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td class="search_shadow"></td>
    </tr>
    <tr>
        <td class="main_blank"></td>
    </tr>
</table>

<!--数据列表-START-->
<ec:table items="COURSE" var="row"
    action="login?ActionType=course_select"
    view="html" 
    autoIncludeParameters="false"
     >
    
    <ec:exportXls fileName="courseList.xls" />
    <ec:row>
        <ec:column style="text-align:center;" width="7%" property="rowcount" cell="rowCount" title="序号" sortable="false"/>
        <ec:column property="course_id" style="text-align:center;" escapeAutoFormat="true" sortable="false" title="课程ID" />
        <ec:column property="class_id" style="text-align:center;" escapeAutoFormat="true" sortable="false" title="班级ID" />
        <ec:column property="course_name" style="text-align:center;" escapeAutoFormat="true" sortable="false" title="课程名" />
         <ec:column property="class_name" style="text-align:center;" escapeAutoFormat="true" sortable="false" title="班级" />
      <ec:column property="EDIT" style="text-align:center;" title="操作" viewsDenied="xls">
        	<a href="#" onClick="formPost(window.SearchState,'','login?ActionType=main_select&COURSE_ID=<c:out value="${row.course_id}"/>&CLASS_ID=<c:out value="${row.class_id}"/>&COURSE_NAME=<c:out value="${row.course_name}"/>&CLASS_NAME=<c:out value="${row.class_name}"/>',this);">进入</a> 
        	<a href="#" onClick="formPost(window.SearchState,'','login?ActionType=course_AddInit&FLAG=update&COURSE_NAME=<c:out value="${row.course_name}"/>&CLASS_NAME=<c:out value="${row.class_name}"/>',this);">| 修改</a>

		     <c:choose>
			    <c:when test="${row.isUse == '1'}">
		   			 |  <a href="#" onClick="state_change('<c:out value="${row.userCode}"/>')">停用</a>
			    </c:when>
			    <c:otherwise>
		   			|  <a href="#" onClick="state_change('<c:out value="${row.userCode}"/>')">启用</a>
			    </c:otherwise>
		    </c:choose>
        </ec:column>
       
    </ec:row>
</ec:table>
</body>
</html>